trace("included main.as");

import VideoPlayer;

//prevent any scaling and to keep aligment to top and left corner for embed.
Stage.align = "TL";
Stage.scaleMode = "noScale";
//Stage.showMenu = false;

var videoPlayer = null;

//check to see which config and playlist files are defined, and so to choose which one to use

	//URL param files are 1st priority
	//embed files are 2nd priority
	//for playlist, if URL nor embed are defined, use playlist node in chosen config xml.

//configURL
if(configURL != undefined && configURL != "") {
	configFile = unescape(configURL);
//configEmbed	
} else if (configEmbed != undefined && configEmbed != "") {
	configFile = unescape(configEmbed);
//default config file if all else fails?	
} else {
	configFile = "_xml/config.xml";	
}

//playlistURL
if(playlistURL != undefined && playlistURL != "") {
	_global.playlistFile = unescape(playlistURL);
//playlistEmbed	
} else if (playlistEmbed != undefined && playlistEmbed != "") {
	_global.playlistFile = unescape(playlistEmbed);	
}

//seek ID, navigate to a specific video in playlist
if(vid != undefined && vid != "") {
	_global.seekID = unescape(vid);
} else if(seekId != undefined && seekId != "") {
	_global.seekID = unescape(seekId);
}

//initial volume 
if(vol != undefined && vol != "") {
	_global.vol = unescape(vol);
}

function startPlayer(){
	trace("startPlayer");
	delete this.onEnterFrame;
	videoPlayer = VideoPlayer.start(this, configFile);
};

//this checks to make sure that the browser is returning proper Stage dimensions back to flash
//IE for some reason, doesn't get the proper Stage properties if it is out of the viewable area in the browser (ie. you have to scroll down to see it)
function checkStageProperties() {
	this.onEnterFrame = function() {
		trace("onEnterFrame");
		if(Stage.width != 0 && Stage.height !=0) {
			startPlayer();
		}
	}
}

/* FOR MOTIF */ 
function onInStreamAdLoaded(Void):Void {
	videoAdHolder.controller.adLoaded();
}

function onError() {
	videoAdHolder.controller.adError();
}

checkStageProperties();
